﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public class NonWorkingJobSiteBLL : INonWorkingJobSiteBLL
    {
        private static readonly INonWorkingJobSiteDAL DAL = DataAccess.CreateNonWorkingJobSites();

        private NonWorkingJobSiteInfo Info = new NonWorkingJobSiteInfo();
        private NonWorkingDayInfo nwdInfo = new NonWorkingDayInfo();
        private JobSiteInfo jsInfo = new JobSiteInfo();
        public IList<NonWorkingJobSiteInfo> ListNonWorkingJobSites(int NonWorkingDay)
        {
            nwdInfo.Sequence = NonWorkingDay;
            Info.NonWorkingDay = nwdInfo;
            return DAL.ListNonWorkingJobSites(Info);
        }
        public IList<NonWorkingJobSiteInfo> ListNonWorkingJobSitesBySequence(int Sequence)
        {
            return DAL.ListNonWorkingJobSites(new NonWorkingJobSiteInfo(Sequence));
        }

        public void Insert(int NonWorkingDay, string JobSite, string Remarks, int CreatedBy)
        {
            nwdInfo.Sequence = NonWorkingDay;
            if (JobSite.Length > 0)
                jsInfo.Sequence = Int32.Parse(JobSite);
            //try
            //{
                DAL.Insert(new NonWorkingJobSiteInfo(0, nwdInfo, jsInfo, Remarks, "", CreatedBy, 0));
            //}
            //catch
            //{
            //    throw new Exception("");
            //}

        }
        public void Update(int Sequence, string JobSite, string Remarks, int UpdatedBy)
        {
            if (JobSite.Length > 0)
                jsInfo.Sequence = Int32.Parse(JobSite);
            try
            {
                DAL.Update(new NonWorkingJobSiteInfo(Sequence, nwdInfo, jsInfo, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }

        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                DAL.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
        
    }
}
